gusucode.com > 婚纱摄影网站模版整站源码 1.1 > 婚纱摄影网站模版整站源码 1.1.3/婚纱2/js/glivia.js

    $.fn.extend({
    gliviaBanner: function(Num) {
        $(".BannerContent").css({
            opacity: 0
        });
		function myBrowser(){
			var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
			if (userAgent.indexOf("Firefox") > -1){return "FF";} //判断是否Firefox浏览器
		}
		var gResult = 0;
        var gIndex = 0,
        nowIndex = 0,
        sWidth = document.body.scrollWidth,
        sWidth_inw = window.innerWidth,
        bannerNumber = Num - 1,
        bZ = true,
        bY = true,
        footColor = 0;
		gResult = sWidth/2+52;
		if(myBrowser()=="FF"){gResult = sWidth/2+52;}
        if (sWidth > 2000) {
            $(".gContent").css({
                width: "2000px"
            });
        } else {
            $(".gContent").css({
                width: sWidth_inw
            });
        }
        $(".gLeftButton,.gRightButton").css({
            top: "190px",
            opacity: 0
        });
        $(".gBannerBg").addClass("gst0");
        init();
        $(".gContent").append("<li class='gTitle'><h1>" + gTitle + "</h1></li><li class='gDesc'>" + gDesc + "</li><li class='gBtn'>" + gBtn + "</li>");
        $(".gContent li ").each(function(index, element) {
            $(this).css({
                left: gResult
            });
        });
        for (var i = 0; i < Num; i++) {
            $(".gControl").append("<li></li>").find("li").eq(i).addClass("gBtn" + i);
        }
        $(".gControl li:first").addClass("gTurnGray");
        var st = setInterval(stl, 5000);
        function init() {
            gTitle = $(".BannerContent li").eq(nowIndex).find("h1").text();
            gDesc = $(".BannerContent li").eq(nowIndex).find("span").eq(1).text();
            gBtn = $(".BannerContent li").eq(nowIndex).find("span").eq(2).html();
        }
        function control_status_do(nowIndex) {
            bY = false;
            $(".gControl li").not(".gControl li:eq(" + nowIndex + ")").removeClass("gTurnGray");
            $(".gControl li:eq(" + nowIndex + ")").addClass("gTurnGray");
            $("#GliviaBanner").removeClass();
            $(".gBannerBg").animate({
                opacity: 0
            },
            800, 
            function() {
                $(this).removeClass().addClass("gBannerBg gst" + nowIndex);
            });
            $("#GliviaBanner").addClass("GliviaBanner gst" + nowIndex).animate(function() {
                $(this).removeClass().addClass("GliviaBanner");
            });
            $(".gBannerBg").animate({
                opacity: 1
            },
            1, 
            function() {
                $(this).removeClass().addClass("gBannerBg gst" + nowIndex);
                bY = true;
            });
        }
        function control_content_do() {
            bZ = false;
            init();
            $(".gContent li").animate({
                left: -200
            },
            300).animate({
                left: sWidth + 200
            },
            1, 
            function() {
                $(".gContent li").find("h1").text(gTitle);
                $(".gContent li").eq(1).text(gDesc);
                $(".gContent li").eq(2).find("a").replaceWith(gBtn);
            });
            $(".gContent li").eq(0).animate({
                left: sWidth / 2 - 3 * sWidth / 100
            },
            400).animate({
                left: gResult
            },
            400);
            $(".gContent li").eq(1).animate({
                left: sWidth / 2 -50
            },
            700).animate({
				left:gResult
                //left: sWidth / 2 + 7 * sWidth / 220
            },
            400);
            $(".gContent li").eq(2).animate({
                left: sWidth / 2 
            },
            900).animate({
                left:gResult
            },
            400, 
            function() {
                bZ = true;
            })
        }
        function banner_all_method() {
            control_status_do(nowIndex);
            control_content_do();
            clearInterval(st);
            st = setInterval(stl, 5000);
        }
        $(".gControl li").click(function() {
            if (!bZ || !bY) return;
            nowIndex = $(this).index();
            if (nowIndex == gIndex) return false;
            gIndex = nowIndex;
            banner_all_method();
        })
        $(".gLeftButton").click(function() {
            if (!bZ || !bY) return;
            nowIndex == bannerNum ? nowIndex = 0: ++nowIndex;
            gIndex = nowIndex;
            banner_all_method();
        })
        $(".gRightButton").click(function() {
            if (!bZ || !bY) return;
            nowIndex == 0 ? nowIndex = bannerNumber : nowIndex--;
            gIndex = nowIndex;
            banner_all_method();
        })
        function stl() {
            nowIndex == bannerNumber ? nowIndex = 0: ++nowIndex;
            gIndex = nowIndex;
            control_status_do(nowIndex);
            control_content_do();
        }
        $("#banner_bg").hover(function() {
            $(".gLeftButton,.gRightButton").animate({
                opacity: 1
            },
            500);
        },
        function() {
            $(".gLeftButton,.gRightButton").animate({
                opacity: 0
            },
            500);
        })
        $(".gLeftButton,.gRightButton").click(function() {
            $(this).animate({
                opacity: 0.5
            },
            300, 
            function() {
                $(this).animate({
                    opacity: 1
                },
                500)
            });
        })
    }
})